package persistence.service.impl;

import model.User;
import model.factory.Service;
import persistence.dao.UserDAO;
import persistence.exceptions.RepositoryException;
import persistence.service.UserPersistenceService;

public class UserPersistenceServiceImpl implements UserPersistenceService {

	private final UserDAO userDAO;

	public UserPersistenceServiceImpl(final Service daoService) {
		super();
		this.userDAO = daoService.getService();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Integer save(User user) {
		return userDAO.insertPerson(user);
	}

	@Override
	public String getPosition(int id) throws RepositoryException {

		return userDAO.getPosition(id);
	}

	@Override
	public User getPerson(int id, String op) throws RepositoryException {

		return userDAO.getPerson(id, op);
	}

	@Override
	public int getMinMaxId(String op) throws RepositoryException {

		return userDAO.getMinMaxId(op);
	}

	@Override
	public int insertPerson(User p) throws RepositoryException {

		return userDAO.insertPerson(p);
	}

	@Override
	public void updatePerson(User p) throws RepositoryException {

		userDAO.updatePerson(p);

	}

	@Override
	public void deletePerson(int id) throws RepositoryException {

		userDAO.deletePerson(id);
	}

	@Override
	public User[] searchUser(String user) throws RepositoryException {

		return userDAO.searchUser(user);
	}
}
